package cn.hh.controller;

import cn.hh.god.domain.Buy;
import cn.hh.service.IBuyService;
import cn.hh.util.AjaxResule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/buy")
public class GodController {
    @Autowired
    private IBuyService buyService;

    @PostMapping
    public AjaxResule buy(@RequestBody Buy buy){

        try {
            buyService.buy(buy);
            return AjaxResule.me().setResultObj("购买成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResule().setMessage(e.getMessage());
        }
    }
}
